package com.markc1d.weibo.mapper;

import com.markc1d.weibo.pojo.entity.Blog;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BlogMapper {
    List<Blog> BlogArr();

    @Update({
            "<script>",
            "UPDATE blog",
            "<set>",
            "<if test='blog.content != null'>content = #{blog.content},</if>",
            "<if test='blog.contentImg != null'>contentImg = #{blog.contentImg},</if>",
            "</set>",
            "WHERE id = #{blog.id}",
            "</script>"
    })
    int updateBlog(@Param("blog") Blog blog);

    @Delete("DELETE FROM blog WHERE id = #{id}")
    int deleteBlog(@Param("id") int id);

    void insertBlog(Blog blog);
}
